// Student类
class Student {
    private String name;
    private int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "age: " + age + ", name: " + name;
    }

    @Override
    public int hashCode() {
        return name.hashCode() + age;
    }

    @Override
    public boolean equals(Object o) {
        Student student = null;
        if (o instanceof Student) {
            student = (Student) o;
        }
        return age == student.age && name.equals(student.name);

    }
}

// 测试类
public class StudentHashSetTest {
    public static void main(String[] args) {
        java.util.HashSet<Student> hs = new java.util.HashSet<>();
        Student s1 = new Student("张三", 20);
        Student s2 = new Student("李四", 21);
        Student s3 = new Student("张三", 20);

        hs.add(s1);
        hs.add(s2);
        hs.add(s3);

        for (Student student : hs) {
            System.out.println(student);
        }
    }
}